package com.test.mq.controller;

import com.test.mq.producer.RocketMqProducer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Component
@RestController
@RequestMapping("/message")
public class RocketMqController {

    @Autowired
    private RocketMqProducer rocketMqProducer;

    @RequestMapping("/send")
    public String sendMsg(){
        rocketMqProducer.sendMsg("msg");
        return "success";
    }

    @RequestMapping("/sendTransaction")
    public String sendMessageInTransaction(){
        rocketMqProducer.sendMessageInTransaction("transaction msg");
        return "success";
    }

    @RequestMapping("/sendDelayMessage")
    public String sendDelayMessage(){
        rocketMqProducer.sendDelayMessage("delay msg");
        return "success";
    }

    @RequestMapping("/sendOneWay")
    public String sendOneWay(){
        rocketMqProducer.sendOneWay("oneWay msg");
        return "success";
    }

    @RequestMapping("/syncSendOrderly")
    public String syncSendOrderly(){
        rocketMqProducer.syncSendOrderly("orderly msg");
        return "success";
    }


}